package arsmodeller.model.impl;

import arsmodeller.model.Link;
import arsmodeller.model.ObjectProcessingDiagram;
import arsmodeller.model.Package;
import arsmodeller.model.Thing;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.EObjectContainmentWithInverseEList;
import org.eclipse.emf.ecore.util.InternalEList;

public class ObjectProcessingDiagramImpl extends EObjectImpl implements ObjectProcessingDiagram{
	/**
	 * The cached value of the '{@link #getLinks() <em>Links</em>}' containment
	 * reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getLinks()
	 * @generated
	 * @ordered
	 */
	protected EList<Link> links;

	/**
	 * The cached value of the '{@link #getThings() <em>Things</em>}'
	 * containment reference list. <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @see #getThings()
	 * @generated
	 * @ordered
	 */
	protected EList<Thing> things;

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	protected ObjectProcessingDiagramImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return Package.Literals.OPM_OBJECT_PROCESS_DIAGRAM;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public EList<Link> getLinks() {
		if (links == null) {
			links = new EObjectContainmentWithInverseEList<Link>(
					Link.class, this,
					Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS,
					Package.OPM_LINK__OPD);
		}
		return links;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	public EList<Thing> getThings() {
		if (things == null) {
			things = new EObjectContainmentWithInverseEList<Thing>(
					Thing.class, this,
					Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS,
					Package.OPM_THING__OPD);
		}
		return things;
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public NotificationChain eInverseAdd(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS:
			return ((InternalEList<InternalEObject>) (InternalEList<?>) getLinks())
					.basicAdd(otherEnd, msgs);
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS:
			return ((InternalEList<InternalEObject>) (InternalEList<?>) getThings())
					.basicAdd(otherEnd, msgs);
		}
		return super.eInverseAdd(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS:
			return ((InternalEList<?>) getLinks()).basicRemove(otherEnd, msgs);
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS:
			return ((InternalEList<?>) getThings()).basicRemove(otherEnd, msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS:
			return getLinks();
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS:
			return getThings();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS:
			getLinks().clear();
			getLinks().addAll((Collection<? extends Link>) newValue);
			return;
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS:
			getThings().clear();
			getThings().addAll((Collection<? extends Thing>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS:
			getLinks().clear();
			return;
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS:
			getThings().clear();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc --> <!-- end-user-doc -->
	 * 
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__LINKS:
			return links != null && !links.isEmpty();
		case Package.OPM_OBJECT_PROCESS_DIAGRAM__THINGS:
			return things != null && !things.isEmpty();
		}
		return super.eIsSet(featureID);
	}

}
